"""
@Time ： 2024/4/24 22:20
@Auth ： czm
@File ：LoginPage.py
@IDE ：PyCharm
"""
from common.base import Base


class UserLogin(Base):
    # 定位元素
    user_id_location = ('xpath', '//*[@placeholder="请输入商户编号"]')  # xpath定位商户编号
    user_name_location = ('css selector', '[placeholder="请输入登录账号"]')  # css 标签定位登录账号
    user_password_location = ('css selector', '[placeholder="请输入密码"]')  # css 标签定位密码
    Verification_code_location = ('css selector', '[placeholder="请输入验证码"]')  # css 标签定位验证码
    login_button_location = ('css selector', '.ant-btn')  # css class定位登录按钮
    logo_location = ('xpath', ".//*[@alt='logo']")
    err_userid_location = ('xpath', '//*[text()="商户不存在"]')
    null_id_location = ('xpath', '//*[text()="商户不存在"]')
    null_user_name_location = ('css selector', ".ant-form-item-explain")
    err_null_password_location = ('css selector', '.ant-form-item-explain')
    err_null_verify = ("css selector", ".ant-form-item-explain")

    def input_user_id(self, text):
        # 输入商户编号
        self.send(self.user_id_location, text)

    def input_user_name(self, text):
        # 输入用户名
        self.send(self.user_name_location, text)

    def input_password(self, text):
        # 输入密码
        self.send(self.user_password_location, text)

    def input_verf_code(self, text=''):
        # 输入验证码
        self.send(self.Verification_code_location, text)

    def login_button(self):
        self.click(self.login_button_location)

    def logo_image(self):
        self.click(self.logo_location)

    def get_err_userid_info(self):
        return self.get_text(self.err_userid_location)

    def get_err_null_id_info(self):
        return self.get_text(self.null_id_location)

    def get_err_null_username_info(self):
        return self.get_text(self.null_user_name_location)

    def get_err_null_password(self):
        return self.get_text(self.err_null_password_location)

    def get_err_null_verify(self):
        return self.get_text(self.err_null_verify)
